import {GET_CATE_NAV_LIST,GET_CATE_LIST} from '../constants';
import axios from 'axios'

export function fetchCateNavListAction(){
    return dispatch=>{
       return  axios.post('/appapi/root-ceo-commodity/categoryApi/categoryList',{
           channelId:null,
           isWholeSale:0
       }).then(res=>{
           console.log(res);
           dispatch({type:GET_CATE_NAV_LIST,data : res.data.data.categoryInfo})
       })
    }
}

export function fetchCateListAction(code) {
    return dispatch => {
        return axios.post("/appapi/root-ceo-commodity/categoryApi/commoditiesByCategory", {
            catKey: code,
            ceoStatus: 0,
            channelId: null,
            page: 1,
            pageSize: 1000
        }).then(res => {
            console.log(res);
            //将数据提交给reducer
            dispatch({ type: GET_CATE_LIST, data: res.data.data.commodityInfo })
        })
    }
}